/**
 * Created by Administrator on 2017/5/5 0005.
 */ checkCookie()
var mid= $.cookie('mid')
var token= $.cookie('token')
var next_page='';
var data_back=false
$(window).scroll(function () {
    var windowheight=$(window).height();//窗口高度
    var scrolltop=$('body').scrollTop();//滚动条高度
    var eh=$(document).height();//文本高度
    if(parseInt(windowheight+scrolltop+5)>=eh){
        console.log("加载");
        $('.bot_loading').show()
        if(data_back){
            return false
        }
        data_back=true
        if(next_page==null){
            $('.bot_loading').html('没有更多啦！')
            setInterval(function () {
                $('.bot_loading').fadeOut(800)
            },2000);
            data_back=false
        }else{
            getData({url:next_page,data:{mid:mid,token:token}}, function (data) {
                var html=template('list',data);
                $('.content').append(html)
                $('.bot_loading').hide()
                next_page=data.next_page_url;
                data_back=false
            })
        }

    }else{
        $('.bot_loading').hide()
    }
})
getData({url:my_favorable,data:{mid:mid,token:token}}, function (data) {
    var html=template('list',data)
    $('.content').html(html);
    $('.load').hide()
    var childs=$('.content').find('.list')
    if(childs.length==0){
        $('.content').append('<p style="text-align: center;padding-top: 10px;font-size:15px; line-height: 360px; color: #666;">暂无优惠券</p>')
    }
   next_page=data.next_page_url;
})